package removeDigit;

public class Solution {
    public String removeDigit(String number, char digit) {
        // 移除 128656646  6
        //     12865664
        //     12865646
        String ans = "0";
        for (int i = 0; i < number.length(); i++) {
            if(number.charAt(i) == digit) {
                String t = number.substring(0,i);
                if(i<number.length()-1) t += number.substring(i+1,number.length());
                if(bigger(t,ans)) ans = t;
            }
        }
        return ans;
    }
    private boolean bigger(String a,String b) {
        if(a.length()!=b.length()) return a.length()>b.length();
        for (int i = 0; i < a.length(); i++) {
            // 比较字符串的大小
            if(a.charAt(i)>b.charAt(i)) return true;
            if(a.charAt(i)<b.charAt(i))return false;
        }
        return false;
    }
}
